package com.SouthernWall_404.AgeSuitcase.Common.API;

import com.SouthernWall_404.AgeSuitcase.Common.AgeSuitcase;

import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
import java.util.Random;

public class GeneralAPI {


    public static String GUI="gui."+ AgeSuitcase.MODID+".";

    public static String getLongStringFromList(List<String> strings)
    {
        if(strings==null)
        {
            return "";
        }
        String longString="";
        for(int i=0;i<strings.size()-1;i++)
        {
            longString=longString+strings.get(i)+",";
        }
        longString=longString+strings.get(strings.size()-1);
        return longString;
    }

    public static String getDate()
    {
        SimpleDateFormat formatter= new SimpleDateFormat("yyyy/MM/dd");
        Date date = new Date(System.currentTimeMillis());
        date.setYear(date.getYear()-150);

        LocalDate today = LocalDate.now(ZoneId.systemDefault());

        // 获取当前日期是周几
        DayOfWeek dayOfWeek = today.getDayOfWeek();

        return formatter.format(date).toString()+","+dayOfWeek.name();
    }

    public static String getCode()
    {
        Random random = new Random();
        int code=random.nextInt(1000000000);
        String codeString=""+code;

        String toFill="";
        if(codeString.length()<10)
        {
            for(int i=0;i<(10-codeString.length());i++)
            {
                toFill=toFill+"0";
            }
        }
        codeString=toFill+codeString;


        return codeString;

    }

    public static int estimite(float f)
    {
        return (f-(int)f)>0.5?((int)f+1):(int)f;
    }
}
